package com.gupao.springbootmybatis.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author hongdu
 * @desc 描述 todo
 * @cankao https://hduclub.cn
 * @gitee https://gitee.com/hongdu_dudua1
 * @createtime 2021/4/12 17:05
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class SwaggerConfiguration {


    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("1.0版本")
                .select()
                // 这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.gupao.springbootmybatis.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("app项目接口文档")
                .description("app项目")
                .termsOfServiceUrl("http://IP:PORT/{contextPath}/doc.html")
                .contact(new Contact("hongdu", "http://answer", "15574948314@163.com"))
                .license("app service")
                .licenseUrl("https://gitee.com/hongdu_dudua1/springboot-mybatis-demo")
                .version("1.0")
                .build();
    }

}
